package day06;

import java.util.Scanner;

public class homework05 {
    /**
     * 5.将一个字符串进行反转，可以指定部分反转
     * abcdefg--->abfedcg
     */
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("输入一个字符串:");
        String str = sc.next();
        System.out.println(reverse(str,1,4));
    }
    public static String reverse(String str,int start,int end){

        if(str != null){
            char[] arr = str.toCharArray();
            for(int i = start,j = end;i < j;i++,j--){
                char temp = arr[i];
                arr[i] = arr[j];
                arr[j] = temp;
            }

            return new String(arr);
        }
        return null;
    }
}

